<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script>

    <style>
        .user-profile-header {
            height: 150px
        }

        .user-profile-avatar[data-v-d1dbb6f8] {
            position: absolute;
            top: -12px;
            width: 102px;
            height: 102px;
            border: 4px solid #f0f0f2;
            border-radius: 50%;
            background: #fff;
        }

        .user-profile-avatar img[data-v-d1dbb6f8] {
            width: 100%;
            height: 100%;
            display: block;
            border-radius: 50%;
        }

        .article-type-img {
            width: 26px;
            height: 22px;
            line-height: 32px;
        }

        .tab-ul > ul[data-v-bb5f5e3e] {
            width: 100%;
            height: 100%;
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            font-size: 14px;
            font-weight: 500;
        }

        ul[data-v-bb5f5e3e] {
            padding: 0;
            margin: 0;
            list-style-type: none;
            list-style: none;
        }

        .tab-ul > ul > li[data-v-bb5f5e3e] {
            line-height: 40px;
            color: #222226;
            height: 100%;
            padding: 0 24px;
            text-align: center;
            cursor: pointer;
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-align: center;
            -ms-flex-align: center;
            align-items: center;
            position: relative;
        }

    </style>


</head>
<body>
<nav class="navbar navbar-default .navbar-fixed-top">
    <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="/home/">七仔家园</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li class="active"><a href="/home/">博客 <span class="sr-only">(current)</span></a></li>
                <li><a href="#">学堂</a></li>
            </ul>
            <!--<form class="navbar-form navbar-left">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="Search">
                </div>
                <button type="submit" class="btn btn-default">搜索</button>
            </form>-->
            <ul class="nav navbar-nav navbar-right">
                {% if request.user.is_authenticated %}
                    <li><a href="/mysite/{{ request.user.username }}/">{{ request.user.username }}</a></li>
                    <li><a href="/mysite/publish/article/">发布</a></li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                           aria-expanded="false">更多操作 <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="#" data-toggle="modal" data-target=".bs-example-modal-lg">修改密码</a></li>
                            <li role="separator" class="divider"></li>
                            <li><a href="/user/logout/">退出登录</a></li>
                        </ul>
                    </li>
                    <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog"
                         aria-labelledby="myLargeModalLabel">
                        <div class="modal-dialog modal-lg" role="document">
                            <div class="modal-content">
                                <div class="container-fluid">
                                    <div class="row">
                                        <div class="col-md-8 col-md-offset-2">
                                            <h2 class="text-center">修改密码</h2>
                                            <div class="form-group">
                                                <label for="">用户名:</label>
                                                <input type="text" class="form-control"
                                                       value="{{ request.user.username }}" disabled>
                                            </div>
                                            <div class="form-group">
                                                <label for="old_password">原密码:</label>
                                                <input type="password" class="form-control" id="old_password"
                                                       username="old_password">
                                            </div>
                                            <div class="form-group">
                                                <label for="new_password">新密码:</label>
                                                <input type="password" class="form-control" id="new_password"
                                                       username="new_password">
                                            </div>
                                            <div class="form-group">
                                                <label for="confirm_password">原密码:</label>
                                                <input type="password" class="form-control" id="confirm_password"
                                                       username="confirm_password">
                                            </div>
                                            <br>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-default" data-dismiss="modal">
                                                    取消
                                                </button>
                                                <button type="button" class="btn btn-primary" id="id_commit">保存</button>
                                                <span style="color: red" id="error"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                {% else %}
                    <li><a href="/user/register/">注册</a></li>
                    <li><a href="/user/login/">登录</a></li>
                {% endif %}
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
<br>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-10 col-md-offset-1">
            <div class="panel panel-default">
                <div class="panel-body user-profile-header">
                    <div class="user-profile-avatar " data-v-d1dbb6f8>
                        <img src="/media/{{ user_obj.avatar }}/" alt="" data-v-d1dbb6f8>
                    </div>
                    <div style="float: left; margin-left: 110px">
                        <ul style="list-style-type: none">
                            <li style="font-size: 20px"><span>{{ user_obj.username }}</span></li>
                            <br>
                            <li>个人简介：</li>
                            <li>加入七仔家园时间:&nbsp&nbsp{{ user_obj.create_time|date:'Y-m-d' }}</li>
                            <li>博客简介:&nbsp&nbsp{{ blog_obj.site_desc }}</li>
                        </ul>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-3">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">兴趣领域</h3>
                        </div>
                        <div class="panel-body">
                            <p>python</p>
                            <p>mysql</p>
                            <p>linux</p>
                            <p>算法与数据结构</p>
                        </div>
                    </div>
                </div>
                <div class="col-md-9">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <div>

                                <!-- Nav tabs -->
                                <ul class="nav nav-tabs" role="tablist">
                                    <li role="presentation" class="active"><a href="#home" aria-controls="home"
                                                                              role="tab"
                                                                              data-toggle="tab">文章</a></li>
                                    <li role="presentation"><a href="#profile" aria-controls="profile" role="tab"
                                                               data-toggle="tab">问答</a>
                                    </li>
                                    <li role="presentation"><a href="#messages" aria-controls="messages" role="tab"
                                                               data-toggle="tab">课程</a>
                                    </li>
                                </ul>

                                <!-- Tab panes -->
                                <div class="tab-content">
                                    <div role="tabpanel" class="tab-pane active tab-ul" id="home">
                                        <!--<ul data-v-bb5f5e3e>
                                            {% load static %}
                                            <li data-v-bb5f5e3e class="second-active action time">
                                                <a href="">按最后发布时间</a>
                                                <img data-v-bb5f5e3e
                                                     style="margin: 0; padding: 0;height: 17px;width: 15px"
                                                     src="{% static 'img/sort/black.png' %}" alt="">
                                            </li>
                                            <li data-v-bb5f5e3e class="action">
                                                <a href="">按访问量</a>
                                                <img data-v-bb5f5e3e
                                                     style="margin: 0; padding: 0;height: 17px;width: 15px"
                                                     src="{% static 'img/sort/black.png' %}" alt="">
                                            </li>
                                        </ul> -->
                                        <hr>
                                        <ul class="media-list">
                                            {% for article_obj in page_queryset %}
                                                <li>
                                                    <div class="media">
                                                        <h4 class="media-heading"><a
                                                                href="/home/{{ article_obj.blog.user.username }}/article/{{ article_obj.id }}/">{{ article_obj.title }}</a>
                                                        </h4>
                                                        <br>
                                                        <div class="media-body">
                                                            {{ article_obj.desc }}
                                                        </div>
                                                    </div>
                                                </li>
                                                <br>
                                                <div>
                                                    <span>
                                                        {% load static %}
                                                        <img class="article-type-img"
                                                             src="{% static  article_obj.type_link %}" alt="">&nbsp&nbsp
                                                    </span>
                                                    <span>发布于</span>
                                                    <span>{{ article_obj.create_time|date:'Y-m-d' }}&nbsp;&nbsp;</span>
                                                    <span>{{ article_obj.visitor_num }}&nbsp阅读&nbsp&nbsp</span>
                                                    <span><span
                                                            class="glyphicon glyphicon-comment"></span>评论({{ article_obj.comment_num }})&nbsp;&nbsp;</span>
                                                    <span><span
                                                            class="glyphicon glyphicon-thumbs-up"></span>点赞({{ article_obj.up_num }})&nbsp;&nbsp;</span>
                                                    <span><span
                                                            class="glyphicon glyphicon-thumbs-down"></span>点踩({{ article_obj.down_num }})</span>
                                                </div>
                                                <hr>
                                            {% endfor %}
                                            {{ page_obj.page_html|safe }}
                                        </ul>
                                    </div>
                                    <div role="tabpanel" class="tab-pane" id="profile">

                                    </div>
                                    <div role="tabpanel" class="tab-pane" id="messages">

                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
</div>


<div class="container-fluid">
    <div class="row">
        <div class="col-md-3">

        </div>
        <div class="col-md-9">

        </div>
    </div>
</div>

<script>
    //修改密码js
    $('#id_commit').click(function (){
        $.ajax({
            url: '/user/set_password/',
            type: 'post',
            data: {"username": $('#username').val(),
                    "old_password": $('#old_password').val(),
                    "new_password": $('#new_password').val(),
                    "confirm_password": $('#confirm_password').val(),
                    "csrfmiddlewaretoken": '{{ csrf_token }}'
            },
            success: function (args){
                if(args.code === 1000){
                    window.location.reload()
                }else{
                    $('#error').text(args.msg)
                }
            }
        })
    })
</script>
</body>

</html>